Set

interface Set<out E> : Collection<E>

A generic unordered collection of elements that does not support duplicate elements. Methods in this interface support only read-only access to the set; read/write access is supported through the MutableSet interface.

Parameters

E

the type of elements contained in the set. The set is covariant in its element type.

Functions

contains
Link copied to clipboard
abstract operator override fun contains(element: @UnsafeVariance E): Boolean
containsAll
Link copied to clipboard
abstract override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
isEmpty
Link copied to clipboard
abstract override fun isEmpty(): Boolean
iterator
Link copied to clipboard
abstract operator override fun iterator(): Iterator<E>

Properties

size
Link copied to clipboard
abstract override val size: Int

Inheritors

AbstractSet
Link copied to clipboard
MutableSet
Link copied to clipboard

Extensions

minus
Link copied to clipboard
operator fun <T> Set<T>.minus(element: T): Set<T>

Returns a set containing all elements of the original set except the given element.

operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements array.

operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements collection.

operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T>

Returns a set containing all elements of the original set except the elements contained in the given elements sequence.

minusElement
Link copied to clipboard
inline fun <T> Set<T>.minusElement(element: T): Set<T>

Returns a set containing all elements of the original set except the given element.

orEmpty
Link copied to clipboard
inline fun <T> Set<T>?.orEmpty(): Set<T>

Returns this Set if it's not null and the empty set otherwise.

plus
Link copied to clipboard
operator fun <T> Set<T>.plus(element: T): Set<T>

Returns a set containing all elements of the original set and then the given element if it isn't already in this set.

operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T>

Returns a set containing all elements of the original set and the given elements array, which aren't already in this set.

operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T>

Returns a set containing all elements of the original set and the given elements collection, which aren't already in this set. The returned set preserves the element iteration order of the original set.

operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T>

Returns a set containing all elements of the original set and the given elements sequence, which aren't already in this set.

plusElement
Link copied to clipboard
inline fun <T> Set<T>.plusElement(element: T): Set<T>

Returns a set containing all elements of the original set and then the given element if it isn't already in this set.